<template>
  <div class="shoplist" :style="{marginBottom: isBottom ? '50px' : 0}">
    <header class="header" v-show="title">{{title}}</header>
    <van-skeleton title :row="row" :loading="loading">
      <div class="wrapper">
        <div class="shop-item" v-for="item in shoplist" :key="item.goodsId" @click="seeDetail(item)">
          <img :src="$filters.imgPrefix(item.goodsCoverImg)">
          <div class="shop-desc">
            <div class="title">{{item.goodsName}}</div>
            <div class="price">¥ {{item.sellingPrice}}</div>
          </div>
        </div>
      </div>
    </van-skeleton>
  </div>
</template>

<script setup>
import {ref} from 'vue'

defineProps({
  row: {
    type: Number,
    default: 3
  },
  title: {
    type: String,
    default: ''
  },
  isBottom: {
    type: Boolean,
    default: false
  },
  shoplist: {
    type: Array,
    required: true,
    default: () => []
  }
})
const emits = defineEmits(['seeDetail'])

const loading = ref(true)
setTimeout(() => loading.value = false, 1000)

// 查看详情
function seeDetail(item) {
  emits('seeDetail', item)
}
</script>

<style lang="less" scoped>
@import '@/assets/style/var.less';

.shoplist {
  background-color: #f8f8f8;
  .header {
    // background: #f9f9f9;
    height: 50px;
    line-height: 50px;
    text-align: center;
    color: @primary;
    font-size: 16px;
    font-weight: 500;
  }
  .wrapper {
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    .shop-item {
      box-sizing: border-box;
      width: calc(50% - 20px);
      padding: 10px 0;
      margin: 10px;
      background-color: #fff;
      // border-bottom: 1PX solid #e9e9e9;
      img {
        display: block;
        width: 120px;
        margin: 0 auto;
      }
      .shop-desc {
        text-align: center;
        font-size: 14px;
        padding: 10px 0;
        .title {
          color: #222333;
        }
        .price {
          color: @primary;
        }
      }
      &:nth-child(2n + 1) {
        // border-right: 1PX solid #e9e9e9;
      }
    }
  }
}
</style>